package com.cw.jeeyt.service.converter.system;
import java.util.List;
import java.util.ArrayList;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.system.SysScaffoldConfigBo;
import com.cw.jeeyt.dao.model.system.SysScaffoldConfigDo;
import com.cw.lang.common.utils.CollectionUtil;
/**
 * 系统脚手架配置转换类
 *
 * @author chenw
 * @date 2020-05-24 21:04:55
 */
public class SysScaffoldConfigConverter{

    /**
     * do转bo
     * @param model
     * @return
     */
    public static SysScaffoldConfigBo do2Bo(SysScaffoldConfigDo model) {
		SysScaffoldConfigBo bo = new SysScaffoldConfigBo();
        if (model == null) {
            return bo;
        }
                bo.setId(model.getId());
                bo.setScaffoldCode(model.getScaffoldCode());
                bo.setScaffoldName(model.getScaffoldName());
                bo.setPomGroupId(model.getPomGroupId());
                bo.setPomArtifactId(model.getPomArtifactId());
                bo.setPomName(model.getPomName());
                bo.setPomVersion(model.getPomVersion());
                bo.setBasePackage(model.getBasePackage());
                bo.setJavaVersion(model.getJavaVersion());
                bo.setSpringbootVersion(model.getSpringbootVersion());
                bo.setImplodedSpringcloud(model.getImplodedSpringcloud());
                bo.setSpringcloudVersion(model.getSpringcloudVersion());
                bo.setImplodedAlibabaDubbo(model.getImplodedAlibabaDubbo());
                bo.setAlibabaDubboVersion(model.getAlibabaDubboVersion());
                bo.setRegistryCenterType(model.getRegistryCenterType());
                bo.setRegistryVersion(model.getRegistryVersion());
                bo.setDaoHandleType(model.getDaoHandleType());
                bo.setDaoHandleVersion(model.getDaoHandleVersion());
                bo.setCreateBy(model.getCreateBy());
                bo.setCreateTime(model.getCreateTime());
                bo.setUpdateBy(model.getUpdateBy());
                bo.setUpdateTime(model.getUpdateTime());
                return bo;
    }

    /**
     * bo转do
     * @param bo
     * @return
     */
    public static SysScaffoldConfigDo bo2Do(SysScaffoldConfigBo bo) {
		SysScaffoldConfigDo model = new SysScaffoldConfigDo();
        if (bo == null) {
            return model;
        }
                model.setId(bo.getId());
                model.setScaffoldCode(bo.getScaffoldCode());
                model.setScaffoldName(bo.getScaffoldName());
                model.setPomGroupId(bo.getPomGroupId());
                model.setPomArtifactId(bo.getPomArtifactId());
                model.setPomName(bo.getPomName());
                model.setPomVersion(bo.getPomVersion());
                model.setBasePackage(bo.getBasePackage());
                model.setJavaVersion(bo.getJavaVersion());
                model.setSpringbootVersion(bo.getSpringbootVersion());
                model.setImplodedSpringcloud(bo.getImplodedSpringcloud());
                model.setSpringcloudVersion(bo.getSpringcloudVersion());
                model.setImplodedAlibabaDubbo(bo.getImplodedAlibabaDubbo());
                model.setAlibabaDubboVersion(bo.getAlibabaDubboVersion());
                model.setRegistryCenterType(bo.getRegistryCenterType());
                model.setRegistryVersion(bo.getRegistryVersion());
                model.setDaoHandleType(bo.getDaoHandleType());
                model.setDaoHandleVersion(bo.getDaoHandleVersion());
                model.setCreateBy(bo.getCreateBy());
                model.setCreateTime(bo.getCreateTime());
                model.setUpdateBy(bo.getUpdateBy());
                model.setUpdateTime(bo.getUpdateTime());
                return model;
    }

    /**
     * doList转boList
     * @param doList
     * @return
     */
    public static List<SysScaffoldConfigBo> doList2BoList(List<SysScaffoldConfigDo> doList) {
        if(CollectionUtil.isEmpty(doList)){
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), SysScaffoldConfigConverter::do2Bo));
    }

    /**
     * boList转doList
     * @param boList
     * @return
     */
    public static List<SysScaffoldConfigDo> boList2DoList(List<SysScaffoldConfigBo> boList) {
        if(CollectionUtil.isEmpty(boList)){
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), SysScaffoldConfigConverter::bo2Do));
    }
}